package com.jasontools.utils;

import android.util.Log;

public class NicknameUtil {
	
	public static final String STR_JID_RESOURCE_SEPARATOR = "/";
	public static final String STR_JID_NICKNAME_SEPARATOR = "{";
	public static final String STR_JID_NICKNAME_SEPARATOR_REG = "\\{";
	
	public static String getNicknameFromFullJid(String jid) {
		String nickname = "";
		if(jid != null) {
			if (jid.contains(STR_JID_RESOURCE_SEPARATOR)) {
				nickname = jid.split(STR_JID_RESOURCE_SEPARATOR)[1];
				if (nickname.contains(STR_JID_NICKNAME_SEPARATOR)) {
					Log.e("nickname", nickname);
					nickname = nickname.split(STR_JID_NICKNAME_SEPARATOR_REG)[0];
				}
			}
		}
		return nickname;
	}
}
